package itypes

import (
	"server/game/model"
	"server/share/config"

	"github.com/hwcer/logger"
	"github.com/hwcer/updater"
)

var Active = &activeIType{IType: NewIType(config.ITypeActive)}
var Config = &activeIType{IType: NewIType(config.ITypeConfig)} //后台配置的活动

func init() {
	Active.SetCreator(activeCreator)
	Config.SetCreator(activeCreator)

	im := &model.Active{}
	if err := updater.Register(updater.ParserTypeCollection, updater.RAMTypeNone, im, Active, Config); err != nil {
		logger.Panic(err)
	}
}

type activeIType struct {
	*IType
}

func activeCreator(u *updater.Updater, iid int32, val int64) (any, error) {
	var err error
	i := &model.Active{}
	i.Model.Init(u, iid)
	i.OID = Active.ObjectId(u, iid)
	i.Update = u.Unix()
	return i, err
}
